package study.javabasic.communication.pipe;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

/**
 * Created by zhangshuhan on 2019/3/21.
 */
public class ReadData {


    public void readDate(PipedInputStream in) {

        byte[] b = new byte[20];

        try {
            int i = in.read(b);
            while (i != -1) {
                String newDate = new String(b, 0, i);
                System.out.println("read:"+newDate);
                i = in.read(b);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
